home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-03 / qbasicpg.zip / BASEBALL.BAS < prev    next >
BASIC Source File  |  1989-08-31  |  2KB  |  60 lines

  1. ' BASEBALL.BAS
  2. ' This program keeps score for a nine-inning baseball game with a
  3. '   two-dimensional array named scoreboard%.
  4.  
  5. OPTION BASE 1           ' set first array element at 1
  6. DIM scoreboard%(2, 9)   ' dimension 2x9 array for baseball scoreboard
  7.  
  8. ' get team and mascot names
  9.  
  10. visitor$ = "Boston": visitorMascot$ = "Red Sox"
  11. home$ = "Seattle": homeMascot$ = "Mariners"
  12.  
  13. CLS
  14.  
  15. PRINT "Enter runs scored by each team in a nine-inning baseball game."
  16. PRINT
  17.  
  18. FOR inning% = 1 TO 9    ' get number of runs scored in each inning
  19.     PRINT "Inning"; inning%; "-->    "; visitor$;
  20.     INPUT ; ":  ", scoreboard%(1, inning%)
  21.     PRINT "    "; home$;
  22.     INPUT ":  ", scoreboard%(2, inning%)
  23.                         ' ...and keep running total for each team
  24.     visitorScore% = visitorScore% + scoreboard%(1, inning%)
  25.     homeScore% = homeScore% + scoreboard%(2, inning%)
  26. NEXT inning%
  27.  
  28. ' determine the winner of the game and display results
  29.  
  30. PRINT
  31. COLOR 2   ' set foreground color to green for "news flash"
  32.  
  33. IF (visitorScore% > homeScore%) THEN
  34.     PRINT "News Flash:  "; visitorMascot$; " beat "; homeMascot$;
  35.     PRINT visitorScore%; "to"; homeScore%
  36. ELSEIF (homeScore% > visitorScore%) THEN
  37.     PRINT "News Flash:  "; homeMascot$; " beat "; visitorMascot$;
  38.     PRINT homeScore%; "to"; visitorScore%
  39. ELSE
  40.     PRINT "News Flash:  "; visitorMascot$; " tie "; homeMascot$;
  41.     PRINT visitorScore%; "to"; homeScore%
  42. END IF
  43.  
  44. COLOR 7   ' set foreground color to white
  45.  
  46. ' display the final scoreboard
  47.  
  48. PRINT
  49. PRINT "Inning         1    2    3    4    5    6    7    8    9"
  50. PRINT "--------------------------------------------------------"
  51.  
  52. FOR team% = 1 TO 2        ' for each team in the game
  53.     IF (team% = 1) THEN PRINT visitor$,  ELSE PRINT home$,
  54.     FOR inning% = 1 TO 9  ' ...and for each inning in the game...
  55.         PRINT scoreboard%(team%, inning%); "  ";
  56.     NEXT inning%          ' print the number of runs scored
  57.     PRINT
  58. NEXT team%
  59.  
  60.